//
//  CardViewController.m
//  mmosite
//
//  Created by yuan he on 2017/3/2.
//  Copyright © 2017年 qingot. All rights reserved.
//

#import "SettingsViewController.h"
#import "ILSettingTool+MMOSiteSetting.h"
#import "ILSettingKeys.h"

@interface SettingsViewController ()

@property (nonatomic, strong) ILSettingSwitchItem* hideAllImageItem;
@property (nonatomic, strong) ILSettingLabelItem* clearCacheItem;
@property (nonatomic, strong) ILSettingArrowItem* rateUsItem;
@property (nonatomic, strong) ILSettingLabelItem* aboutUsItem;

@end

@implementation SettingsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Settings";
    
    [self setupTableView];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)setupTableView {
    
    // 设置属性
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 49, 0);

    // 第一个Section
    [self add1SectionItems];
    
}


#pragma mark - 添加模型数据
- (void)add1SectionItems
{
    typeof(self) __weak weakSelf = self;
    
    // Hide All Image
    _hideAllImageItem = [ILSettingSwitchItem itemWithTitle:@"Hide all image"];
    _hideAllImageItem.key = kDBHideAllImage;
    _hideAllImageItem.on = [ILSettingTool hideAllImage];
    _hideAllImageItem.operation = ^{
        BMLog(@"_popViewSwitchItem.off  = %d", weakSelf.hideAllImageItem.on);
    };
    
    _clearCacheItem = [ILSettingLabelItem itemWithIcon:@" " title:@"Clear Cache"];
    NSString* cacheSizeStr = [NSString stringWithFormat:@"v %@",[[[NSBundle mainBundle] infoDictionary]objectForKey:(NSString *)kCFBundleVersionKey]];
    _clearCacheItem.text = cacheSizeStr;
    _clearCacheItem.operation = ^{
        BMLog(@"==v4.2.0==");
    };
    
    // Rate Us
    // FIXME: ZYT TEST
    _rateUsItem = [ILSettingArrowItem itemWithIcon:@"" title:@"Rate us"];
    _rateUsItem.operation = ^{
        BMLog(@"==Rate Us==");

    };
    
    // About Us
    _aboutUsItem = [ILSettingLabelItem itemWithIcon:@" " title:@"About Us"];
    NSString* verStr = [NSString stringWithFormat:@"v %@",[[[NSBundle mainBundle] infoDictionary]objectForKey:(NSString *)kCFBundleVersionKey]];
    _aboutUsItem.text = verStr;
    _aboutUsItem.operation = ^{
        BMLog(@"==v4.2.0==");
    };
    
    ILSettingGroup *group = [[ILSettingGroup alloc] init];
    group.items = @[_hideAllImageItem, _clearCacheItem, _rateUsItem, _aboutUsItem];
    [_allGroups addObject:group];
}

@end
